<template>
 <div>
    <el-tree
    :data="treedata"
    show-checkbox
    node-key="id"
    ref="tree"
    default-expand-all
    :default-checked-keys="checkedkeys"
    :props="defaultProps"
  >
  </el-tree>  
  </div>
</template>
<script>
export default {
  data() {
    return {
      treedata: [],
      checkedkeys:[],
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  methods:{
    loadData(){
        let rid =this.$route.query.rid;
        this.$axios.get("http://localhost:9000/userEmp/persTree/"+rid)
        .then(res=>{
            if(res.data.code==200){
                this.treedata=res.data.data.treeList;
                this.checkedkeys=res.data.data.checkedkeys;
            }
        }).catch(error=>{
            this.$message.error("出错了");
        })
    }
  },
  mounted(){
    this.loadData();
  }
};
</script>